package com.uetoken.cn.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;

import com.blankj.utilcode.util.ToastUtils;
import com.uetoken.cn.R;
import com.uetoken.cn.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author : hejunming
 * e-mail : 925379434@qq.com
 * date   : 2018/10/16 11:34
 */
public class WebDebugActivity extends BaseActivity {

    @BindView(R.id.webDebugEt)
    EditText webDebugEt;
    @BindView(R.id.doWebDebugBtn)
    Button doWebDebugBtn;
    String urlDefault = "https://url.cn/5tZz8Ic";
    String url;

    @Override
    public int getLayoutId() {
        return R.layout.activity_web_debug;
    }

    @Override
    public void initView() {
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {

    }

    @Override
    public void init() {

    }


    @OnClick(R.id.doWebDebugBtn)
    public void onViewClicked() {
//        toWebActivity(url);
        url = webDebugEt.getText() + "";
        if (url.contains("http")) {
            toWebActivity(url);
        } else {
            url = urlDefault;
            toWebActivity(url);
            ToastUtils.showShort("你输入的URL是错误的，当前打开的是默认的URL");
        }
    }

    private void toWebActivity(String url) {
        Intent intent = new Intent(WebDebugActivity.this, WebActivity.class);
        intent.putExtra("url", url);
        startActivity(intent);
    }
}
